import 'dart:async';

class DataBloc2 {
  // 定义Controller
  StreamController<String> dataController = StreamController();

  // 获取StreamSink做add入口
  StreamSink<String> get _dataSink => dataController.sink;

  // 不要添加监听
  late Stream<String> stream;

  DataBloc2() {
    stream = dataController.stream;
  }

  add(String s) {
    _dataSink.add(s);
  }

  close() {
    dataController.close();
  }
}
